/**
 * JavaScript array library.
 * @author shenw
 */
(function(){
	var root = pack('jshen.array');
	/**
	 * Add element from src array to desc array.
	 * @param {Array} srcArray
	 * @param {int} beginIndex
	 * @param {int} length
	 */
	Array.method('add',function(src, beginIndex, length){
		var s,l;
		if (beginIndex) {
			s = beginIndex;
		} else {
			s = 0;
		}
		if (length) {
			l = length;
		} else {
			l = src.length;
		}
		for (var i = 0; i < l; i++) {
			this.push(src[i+s]);
		}
		return this;
	});
	/**
	 * Found index of the value in array.
	 * @param {Object} value
	 * @return {int} index(if can not found, return -1)
	 */
	Array.method('index', function(value){
		for (var i=0; i < this.length; i++) {
			if (value === this[i]) {
				return i;
			}
		}
		return -1;
	});
	/**
	 * Detect object is array.
	 * @param {Object} value
	 */
	root.method('isArray', function(value){
	    return value &&
	    typeof value === 'object' &&
	    typeof value.length === 'number' &&
	    typeof value.splice === 'function' &&
	    !(value.propertyIsEnumerable('length'));	
	});
})();
